#coding=utf-8

# Project: OaixLouder
# Author : Xiao Xiangquan
# Date   : 2010.11.12

import mechanize
import Tkinter

class base_client:
    def __init__(self, config ):
        self.config = config
        self.browser = mechanize.Browser()

    def post_blog(self, title, content ):
        pass

    def post_topic(self, title, content):
        pass

    def post_microblog(self, content):
        pass

    def display_blog_option(self, father, name, call_browser ):
        self.var_blog_user = Tkinter.StringVar()
        self.var_blog_user.set( self.config["blog_user"] )
        self.var_blog_password = Tkinter.StringVar()
        self.var_blog_password.set( self.config["blog_password"] )
        self.btn_blog_state = Tkinter.Button( father, width=5, text=name, command=call_browser )

        self.btn_blog_state.grid( row=0, column=1, sticky=Tkinter.W )
        Tkinter.Label( father, text="用户名" ).grid(                                            row=0, column=2, sticky=Tkinter.W )
        Tkinter.Entry( father, width=10, textvariable=self.var_blog_user ).grid(               row=0, column=3, sticky=Tkinter.W )
        Tkinter.Label( father, text="密码" ).grid(                                              row=0, column=4, sticky=Tkinter.W )
        Tkinter.Entry( father, width=10, textvariable=self.var_blog_password, show="*" ).grid( row=0, column=5, sticky=Tkinter.W )

    def display_forum_option(self, father, name, call_browser ):
        self.var_forum_user = Tkinter.StringVar()
        self.var_forum_user.set( self.config["forum_user"] )
        self.var_forum_password = Tkinter.StringVar()
        self.var_forum_password.set( self.config["forum_password"] )
        self.btn_forum_state = Tkinter.Button( father, width=5, text=name, command=call_browser )

        self.btn_forum_state.grid( row=0, column=1, sticky=Tkinter.W )
        Tkinter.Label( father, text="用户名" ).grid(                                            row=0, column=2, sticky=Tkinter.W )
        Tkinter.Entry( father, width=10, textvariable=self.var_forum_user ).grid(               row=0, column=3, sticky=Tkinter.W )
        Tkinter.Label( father, text="密码" ).grid(                                              row=0, column=4, sticky=Tkinter.W )
        Tkinter.Entry( father, width=10, textvariable=self.var_forum_password, show="*" ).grid( row=0, column=5, sticky=Tkinter.W )

    def display_microblog_option(self, father, name, call_browser ):
        self.var_microblog_user = Tkinter.StringVar()
        self.var_microblog_user.set( self.config["microblog_user"] )
        self.var_microblog_password = Tkinter.StringVar()
        self.var_microblog_password.set( self.config["microblog_password"] )
        self.btn_microblog_state = Tkinter.Button( father, width=5, text=name, command=call_browser )

        self.btn_microblog_state.grid( row=0, column=1, sticky=Tkinter.W )
        Tkinter.Label( father, text="用户名" ).grid(                                                 row=0, column=2, sticky=Tkinter.W )
        Tkinter.Entry( father, width=10, textvariable=self.var_microblog_user ).grid(               row=0, column=3, sticky=Tkinter.W )
        Tkinter.Label( father, text="密码" ).grid(                                                   row=0, column=4, sticky=Tkinter.W )
        Tkinter.Entry( father, width=10, textvariable=self.var_microblog_password, show="*" ).grid( row=0, column=5, sticky=Tkinter.W )

    def update_config(self):
        pass